package com.apipay.config;


import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

public class AlipayConfig {
    /**
     * 应用号
     */
    public static String APP_ID = "你的沙箱中appId";
    /**
     * 商户的私钥
     */
    public static String APP_PRIVATE_KEY = "你的私钥";
    /**
     * 编码
     */
    public static String CHARSET = "UTF-8";
    /**
     * 支付宝公钥
     */
    public static String ALIPAY_PUBLIC_KEY = "你的公钥，和私钥配对加解密使用";
    /**
     * 支付宝网关地址
     */
    private static String GATEWAY = "https://openapi.alipay.com/gateway.do";
    /**
     * 成功付款回调
     */
    public static String PAY_NOTIFY = "你的回调地址";
    /**
     * 支付成功回调
     */
    public static String REFUND_NOTIFY = "你的回调地址";
    /**
     * 前台通知地址
     */
    public static String RETURN_URL = "你的回调地址";
    /**
     * 参数类型
     */
    public static String PARAM_TYPE = "json";
    /**
     * 成功标识
     */
    public static final String SUCCESS_REQUEST = "TRADE_SUCCESS";
    /**
     * 交易关闭回调(当该笔订单全部退款完毕,则交易关闭)
     */
    public static final String TRADE_CLOSED = "TRADE_CLOSED";
    /**
     * 收款方账号
     */
    public static final String SELLER_ID = "注册沙箱的支付宝账号";
    /**
     * 支付宝请求客户端入口
     */
    private volatile static AlipayClient alipayClient = null;

    /**
     * 不可实例化
     */
    private AlipayConfig() {
    }

    ;

    /**
     * 双重锁单例
     *
     * @return 支付宝请求客户端实例
     */
    public static AlipayClient getInstance() {
        if (alipayClient == null) {
            synchronized (AlipayConfig.class) {
                if (alipayClient == null) {
                    alipayClient = new DefaultAlipayClient(GATEWAY, APP_ID, APP_PRIVATE_KEY, PARAM_TYPE, CHARSET, ALIPAY_PUBLIC_KEY);
                }
            }
        }
        return alipayClient;
    }

}


